//
//  AuthArchieveHelper.m
//  ZYTools
//
//  Created by ZhàoYǒng on 06/11/2017.
//  Copyright © 2017 ZhàoYǒng. All rights reserved.
//

#import "AuthArchieveHelper.h"

@implementation AuthArchieveHelper

+ (NSString *)account {
    return [NSUserDefaults.standardUserDefaults objectForKey:@"zy_account"];
}

+ (NSNumber *)authId {
    return [NSUserDefaults.standardUserDefaults objectForKey:@"zy_authId"];
}

+ (NSString *)token {
    return [NSUserDefaults.standardUserDefaults objectForKey:@"zy_token"];
}

+ (NSString *)password {
    return [NSUserDefaults.standardUserDefaults objectForKey:@"zy_password"];
}

+ (id<NSCoding>)attri0 {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    NSData *encodedObject = [defaults objectForKey:@"zy_attri0"];
    return [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
}

+ (id<NSCoding>)attri1 {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    NSData *encodedObject = [defaults objectForKey:@"zy_attri1"];
    return [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
}

+ (void)saveAccount:(NSString *)account {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:account forKey:@"zy_account"];
    [defaults synchronize];
}

+ (void)saveAuthId:(NSNumber *)authId {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:authId forKey:@"zy_authId"];
    [defaults synchronize];
}

+ (void)saveToken:(NSString *)token {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:token forKey:@"zy_token"];
    [defaults synchronize];
}

+ (void)savePassword:(NSString *)password {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:password forKey:@"zy_password"];
    [defaults synchronize];
}

+ (void)saveAttri0:(id<NSCoding>)attri0 {
    NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:attri0];
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:encodedObject forKey:@"zy_attri0"];
    [defaults synchronize];
}

+ (void)saveAttri1:(id<NSCoding>)attri1 {
    NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:attri1];
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults setObject:encodedObject forKey:@"zy_attri1"];
    [defaults synchronize];
}

+ (void)removeAccount {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_account"];
}

+ (void)removeAuthId {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_authId"];
}

+ (void)removeToken {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_token"];
}

+ (void)removePassword {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_password"];
}

+ (void)removeAttri0 {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_attri0"];
}

+ (void)removeAttri1 {
    NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
    [defaults removeObjectForKey:@"zy_attri1"];
}

@end
